<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('计划列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row" id="printArea">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <input type="hidden" name="orderId" th:value="${orderId}"/>
                        <input id="status" name="status" value="2,3" type="hidden">

                        <input id="planType" name="planType" value="1" type="hidden">

                        <li>
                            计划编号：<input type="text" name="planCode"/>
                        </li>
                        <li>
                            作物名称：<input type="text" name="cropNameCn"/>
                        </li>
                        <li>
                            作物品种：<input type="text" name="cropVarietiesCn"/>
                        </li>
                        <li class="select-time">
                            <label>育苗： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginPlanTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endPlanTime]"/>
                        </li>
                        <li>
                            生产班组：<input type="text" name="teamCn"/>
                        </li>

                        <!--<li>
                            计划制定人：<input type="text" name="createBy"/>
                        </li>-->


                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ncPlan:add">
                <i class="fa fa-plus"></i> 添加
            </a>

            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:ncPlan:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-info" onclick="$.table.importExcel()">
                <i class="fa fa-upload"></i> 导入
            </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:ncPlan:export">
                <i class="fa fa-download"></i> 导出
            </a>

        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>


    </div>
    <div class="bottom-btns"></div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncPlan:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncPlan:remove')}]];
    var prefix = ctx + "system/ncPlan";

    var landType = [[${@dict.getType('landType')}]];
    $(function () {
        var options = {
            url: prefix + "/list?planType=1&status=2,3&orderId="+(![[${orderId}]]?0:[[${orderId}]]),
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            importUrl: prefix + "/importData",
            importTemplateUrl: prefix + "/importTemplate",
            modalName: "计划",
            sortName:'planTime',
            sortOrder:'desc',
            showExport: true,
            columns: [
                {
                checkbox: true
            },
                {
                    field: 'planId',
                    title: '计划id',
                    visible: false
                },{
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'planCode',
                    title: '计划编号',
                    sortable: true,
                },
                {
                    field: 'cropNameCn',
                    title: '作物名称',
                },
                {
                    field: 'cropVarietiesCn',
                    title: '作物品种',
                },
                {
                    field: 'planTime',
                    title: '育苗时间',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return dateFtt(value);
                    }

                },
                {
                    field: 'teamCn',
                    title: '生产班组',
                    sortable: true
                },
                {
                    field: 'chaci',
                    title: '茬次',
                    sortable: true
                },
                {
                    field: 'count',
                    title: '数量(株)',
                    sortable: true
                },
                {
                    field: 'plateCount',
                    title: '盘数',
                    sortable: true
                },
                {
                    field: 'cycleDays',
                    title: '循环天数',
                    sortable: true
                },
                {
                    field: 'area',
                    title: '单茬面积(亩)',
                    sortable: true
                },
                {
                    field: 'jian',
                    title: '间数',
                    sortable: true
                },
                {
                    field: 'createTime',
                    title: '计划制定时间',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'createBy',
                    title: '计划制定人'
                },
                {
                    field: 'standard.standardName',
                    title: '标准名称',

                },
                {
                    field: 'status',
                    title: '状态',

                    formatter: function (value, row, index) {
                        /*状态 1:待生成订单 2：待执行 3.在执行 4.已完成*/
                        if (value == 1) {
                            return '<span class="badge badge-warning">待生成订单</span>'
                        } else if (value == 2) {
                            return '<span class="badge badge-info">待执行</span>'
                        } else if (value == 3) {
                            return '<span class="badge badge-primary">在执行</span>'
                        } else if (value == 4) {
                            return '<span class="badge badge-success">已完成</span>'
                        } else {
                            return "--";
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                },
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (!row.standardId) {
                            actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="editStandard(\'' + row.planId + '\')"><i class="fa fa-warning"></i>标准</a> ');
                        }
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.planId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.planId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);

        var btns = [{
            name: '育苗计划单',
            url: ctx + 'system/ncOrder?orderType=2',
            id: 'ym-order'
        }, {
            name: '育苗计划录入',
            url: ctx + 'system/ncPlan/input',
            id: 'ym-input'
        }, {
            name: '工作记录',
            url: ctx + 'system/ncNormalWorks?workType=2',
            id: 'normal-work'
        }]
        addBtns(btns);
    });

    function editStandard(plandId) {
        var url = ctx + 'system/ncPlan/editStandard/' + plandId
        $.modal.open("修改标准", url);
    }

    setTitle("育苗计划",false)
</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <!--                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> 是否更新已经存在的用户数据-->
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>